var CameraFollow = pc.createScript('CameraFollow');

// initialize code called once per entity
CameraFollow.prototype.initialize = function() {
    
    var app = this.app;
    var manager  = app.root.findByName('Manager');
    this.gamemanager = manager.script.GameStateManager;
    this.bound = app.root.findByName('bound');
    this.boundInitpos = this.bound.getPosition().clone();
    this.InitPos = this.entity.getPosition().clone();
    this.movespeed = 5;
    
};

// update code called every frame
CameraFollow.prototype.update = function(dt) {
    if(!this.gamemanager.start || !this.gamemanager.startgame || this.gamemanager.lose)
    {
        return;
    }
    this.bound.translate(0,this.movespeed*dt,0);
};
CameraFollow.prototype.postUpdate = function(dt){
    if(!this.gamemanager.start || !this.gamemanager.startgame || this.gamemanager.lose)
    {
        return;
    }
    this.entity.translate(0,this.movespeed*dt,0);

};

CameraFollow.prototype.Init = function(){
  
    this.entity.setPosition(this.InitPos.x,this.InitPos.y,this.InitPos.z);
    this.bound.setPosition(this.boundInitpos.x,this.boundInitpos.y,this.boundInitpos.z);
    this.movespeed = 5;
};